/*************************************************************************
 * @file: mev.h
 * @date: 01/04/2012
 * TOPOL v1_0 - (c)copyright 2012 TEC/UFF
 *************************************************************************
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 ************************************************************************/

#ifndef _MEV
#define _MEV

// includes
//----------
#include "euleroperator.h"

// forward declarations
//----------------------
class HEDModel;
class HalfEdge;
class Edge;


/*!
 * CLASS
 * MEV
 * 
 * This class implements the Topological Euler Operator: MEV, that means,
 * Make Edge and Vertex.
 * 
 * @author Andre Pereira (andremaues@id.uff.br)
 * @version 1.0.0
 * @see EulerOperator
 */
class MEV : public EulerOperator
{

public:

  ////////////////////////////////////////////////
  ///  Constructor and Destructor Declaration  ///
  ////////////////////////////////////////////////

  /**
   * @brief Creates the Topological Euler Operator MEV
   *        OBS: It corresponds to the smev of Mantyla.
   * @param _model is the model with all topological data
   * @param _s is the identity of the solid that the topological entities are added
   * @param _v1 is the identity of the existing vertex
   * @param _v4 is the identity of the vertex to be created
   * @param _x is the first coordinate of the point
   * @param _y is the second coordinate of the point
   * @param _z is the third coordinate of the point
   */
  MEV( HEDModel& _model, int _s, int _v1, int _v4, double _x, double _y, double _z );

  /**
   * @brief Creates the Topological Euler Operator MEV
   *        OBS: It corresponds to the mev of Mantyla.
   * @param _model is the model with all topological data
   * @param _s is the identity of the solid that the topological entities are added
   * @param _f1 is the identity of the face located the existing vertex
   * @param _f2 is the identity of the face that is kept in the splitting
   * @param _v1 is the identity of the existing vertex
   * @param _v2 is the identity of an existing vertex to obtain one reference half-edge
   * @param _v3 is the identity of an existing vertex to obtain another reference half-edge
   * @param _v4 is the identity of the vertex to be created
   * @param _x is the first coordinate of the point
   * @param _y is the second coordinate of the point
   * @param _z is the third coordinate of the point
   */
  MEV( HEDModel& _model, int _s, int _f1, int _f2, int _v1, int _v2, int _v3, int _v4, double _x, double _y, double _z );

  /**
   * @brief Creates the Topological Euler Operator MEV
   *        OBS: It corresponds to the lmev of Mantyla.
   * @param _model is the model with all topological data
   * @param _he1 is the reference half-edge
   * @param _he2 is the other reference half-edge
   * @param _v is the identity of the vertex to be created
   * @param _x is the first coordinate of the point
   * @param _y is the second coordinate of the point
   * @param _z is the third coordinate of the point
   */
  MEV( HalfEdge* _he1, HalfEdge* _he2, int _v, double _x, double _y, double _z );


  ////////////////////////////////////
  ///  PUBLIC Methods Declaration  ///
  ////////////////////////////////////
		
  /**
   * @brief Asks to execute the current topological operator
   */
  void execute();
		
  /**
   * @brief Asks to execute the inverse topological operator
   */
  void unExecute();


private:

  /////////////////////////////////////
  ///  PRIVATE Methods Declaration  ///
  /////////////////////////////////////

  void checksInputData(HEDModel& _model, int _s, int _f1, int _f2, int _v1, int _v2, int _v3);


  ////////////////////////////////
  ///  Attributes Declaration  ///
  ////////////////////////////////

  /** @brief Half-edge */
  HalfEdge* m_he1;

  /** @brief Half-edge */
  HalfEdge* m_he2;

  /** @brief Identity of the created vertex */
  int m_v;

  /** @brief Coordinate X of the new point  */
  double m_x;

  /** @brief Coordinate Y of the new point */
  double m_y;

  /** @brief Coordinate Z of the new point */
  double m_z;

  /** @brief Is the identity of the origin vertex (it is kept here just for undo/redo purpose) */
  int m_v1;

  /** @brief Contains all topological entities of the model (it is kept here just for undo/redo purpose) */
  HEDModel* m_model;

};

#endif
